{include file="header"}
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">{:lang("system")}</a>
            <a href="">{:lang("user")}</a>
            <a>
              <cite>{:lang("user.edit")}</cite></a>
          </span>

</div>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <input type="hidden" name="id" value="{$user.id}">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red"></span>{:lang("username")}
                </label>
                <div class="layui-form-mid layui-word-aux">
                    {$user.username}
                </div>

            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>{:lang("name")}
                </label>
                <div class="layui-input-block">
                    <input type="text" name="name" placeholder="{:lang('please.enter')}{:lang('name')}" autocomplete="off" class="layui-input" value="{$user.name}">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red"></span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red"></span>{:lang('phone')}
                </label>
                <div class="layui-input-block">
                    <input type="text" name="phone" placeholder="{:lang('please.enter')}{:lang('phone')}" autocomplete="off" class="layui-input" value="{$user.phone}">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red"></span>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>{:lang('roles')}
                </label>
                <div class="layui-input-inline">

                    <select name="roles">
                        {volist name="roles" id="item"}
                        <option value="{$item.id}">{$item.name}</option>
                        {/volist}

                    </select>

                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red"></span>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="add" lay-submit="">
                    {:lang('edit')}
                </button>
            </div>
        </form>
    </div>
</div>
{include file="footer"}
<script>
    layui.use(['form', 'layer'], function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        //监听提交
        form.on('submit(add)', function(data) {

            request("POST",'{:url("user/edit")}',data.field,function (res,msg) {
                //发异步，把数据提交给php

                layer.alert(msg, {icon: 6}, function() {
                    xadmin.close();
                    // 可以对父窗口进行刷新
                    xadmin.father_reload();
                });
            })

            return false;
        });

    });
</script>